package day12;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class TestIterator {
	public static void main(String[] args) {
		List list = new ArrayList();
		list.add("aaa");
		Iterator it =list.iterator();
		//it.remove();
		it.next();
		it.remove();
		System.out.println(it.hasNext());
		System.out.println(list.size());
/*		System.out.println(it.next());
		System.out.println(it.next());*/
		while(it.hasNext()){
			it.next();
		}
		list.add("aaa");
		list.add("bbb");
		list.add("ccc");
		list.add("ddd");
		Iterator it1 = list.iterator();
		while(it1.hasNext()){
			Object o = it1.next();
			//list.remove(o);
			it1.remove();
		}
		System.out.println(list.size());
		for(int i=0; i<list.size(); i++){
			Object o = list.get(i);
		}
		System.out.println("======================");
		List list1 = new ArrayList();
		list1.add("aaa");
		list1.add("bbb");
		list1.add("ccc");
		list1.add("ddd");
		ListIterator lit = list1.listIterator();
		/*while(lit.hasPrevious()){
			System.out.println(lit.previous());
		}*/
		/*lit.next();
		lit.next();
		System.out.println(lit.previous());*/
		while(lit.hasNext()){
			System.out.println(lit.next());
		}
		System.out.println("=======================");
		while(lit.hasPrevious()){
			System.out.println(lit.previous());
		}
		System.out.println("=======================");
		lit.next();
		lit.set("ffffffffff");
		lit.previous();
		while(lit.hasNext()){
			System.out.println(lit.next());
		}
	}
}






